/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2025-02-26 16:59:40
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2025-02-28 16:43:23
 * @FilePath: \dwys_web\extensions\phoenix-plugin-client\assets\core\platform\platform.xiaomi.ts
 * @Description: 
 */
import { ErrorLocalCode } from "../defines/error.local.define";
import { IPlatform } from "../interface/platform.interface";
import { PlatformBase } from "./platform.base";

export class PlatformXiaoMi extends PlatformBase implements IPlatform {

    needThirdPlatformLogin(){
        return false;
    }

    login(cb: Function): Promise<string | number | boolean> {
        return new Promise((resolve) => {
            let authCode = false;
            //@ts-ignore
            (qg as any).login({
                success:(res:any)=> {
                    //发起网络请求
                    console.log('xiaomi login back');
                    console.log(res);
                    authCode = res.data.appAccountId;
                    cb(authCode);
                    resolve(0);
                },
                fail: (res:any) => {
                    console.log('xiaomi login back fail');
                    cb('');
                    resolve(ErrorLocalCode.PLATFORM_LOGIN_FAIED);
                },
            });
        });
    }
}